#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
import socket

client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect_ex(("127.0.0.1", 2005))

while True:
    inp = input(">>>>: ").strip()
    if not inp: continue
    client.send("{}".format(inp).encode("utf-8"))
    length = int(client.recv(1024).decode("utf-8"))
    client.send("recv_ready".encode("utf-8"))
    send_size, recv_size = 0, 0
    data = b""
    while recv_size < length:
        data += client.recv(1024)
        recv_size += len(data)
    print(data.decode("utf-8"))
